package me.raih.controller.admin.common;

import me.raih.pojo.po.Category;
import me.raih.pojo.vo.ResultInfo;
import me.raih.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author Raih
 * @Time 2020/12/6  13:52
 *
 * 查找商品分类
 */
@Controller
@RequestMapping(value = "/admin")
public class AdminCategoryController {

    @Autowired
    CategoryService categoryService;

    @Autowired
    ResultInfo resultInfo;

    /**
     * 查找商品分类的  no和名称
     * @return JSON
     */
    @RequestMapping(value = "/toCategory")
    @ResponseBody
    public ResultInfo haveCategory(){

        List<Category> categoryList = categoryService.findCategory();
        resultInfo.setData(categoryList);
        return resultInfo;
    }

}
